import axios from "axios";
import service from "@/config/index";

const URLS = {
  PARSE_ADDRESS: `${service.serviceArea}/parse`,
  CREATE: `${service.serviceOrder}`,
  GET_CREATE_CONFIG: `${service.serviceBasic}/customer/order/defaults`,
  SET_CREATE_CONFIG: `${service.serviceBasic}/customer/order/defaults`
};
export default {
  // 获取收发货地址经纬度
  parseAddress (params) {
    return axios.post(URLS.PARSE_ADDRESS, params);
  },
  analysisAddress (params) {
    return axios.post(`${service.serviceArea}/region/address/analysis`, params);
  },
  // 创建订单
  createOrder (params, type) {
    return axios.post(
      `${URLS.CREATE}/send/${type ? "?type=whole" : "?type=divide"}`,
      params
    );
  },
  // 获取客户配置信息
  getCreateConfig (id) {
    return axios.get(`${URLS.GET_CREATE_CONFIG}/${id}`);
  },
  // 设置创建订单配置信息
  setCreateConfig (params) {
    return axios.post(URLS.SET_CREATE_CONFIG, params);
  },
  orderDetailsApi (orderId) {
    return axios.get(`${service.serviceOrder}/${orderId}`);
  },
  orderGoodsReceiptApi (params) {
    return axios.post(`${service.serviceOrder}/goods/list/receipt`, params);
  },
  orderGoodsSignApi (params) {
    return axios.post(`${service.serviceOrder}/goods/list/sign`, params);
  },
  orderGoodsListApi (params) {
    return axios.post(`${service.serviceOrder}/goods/list/done`, params);
  },
  orderScoreApi () {
    return axios.post(`${service.serviceOrder}/score`);
  },
  goodsSaveApi (type, params) {
    return axios.post(`${service.serviceOrder}/orderGoods/${type}`, params);
  },
  goodsDeleteApi (type, orderGoodsId) {
    return axios.put(
      `${service.serviceOrder}/orderGoods/${type}/${orderGoodsId}`
    );
  },
  modeApi (type, code) {
    return axios.get(`/ere/track/getThirdTrack/${type}/${code}`);
  },
  deviceApi (page = 1, pageSize = 100, devCode) {
    return axios.get(`/ere/device/list/${page}/${pageSize}/${devCode}`);
  },
  showDeviceApi (devCode) {
    return axios.get(`/ere/device/getByDevCode/${devCode}`);
  },
  // 修改订单
  updateOrder (orderId, params) {
    return axios.put(`${service.serviceOrder}/${orderId}`, params);
  },
  // 订单导入${service.serviceOrder}
  importExcel (file) {
    return axios.post(`${service.serviceOrder}/readExcel`, file, {
      timeout: 200000
    });
  },
  // 回单
  receipt (params) {
    return axios.post(`${service.serviceOrder}/receipt`, params);
  },
  // 订单批量回单
  receiptBatch (params) {
    return axios.post(`${service.serviceOrder}/receipt/batch`, params);
  },

  // 签收
  sign (params) {
    return axios.post(`${service.serviceOrder}/sign`, params);
  },
  // 获取详情（修改、复制）
  orderDetail (orderId) {
    return axios.get(`${service.serviceOrder}/original/data/${orderId}`);
  },
  // 获取批量操作结果
  getTaskLog () {
    return axios.post(`${service.serviceOrder}/notice/task`, {});
  },
  // 获取批量操作结果
  getReadTaskLog () {
    return axios.post(`${service.serviceOrder}/notice/task/mark/read`, {});
  },

  //验证重复合同编号
  validateRepeatContractNo (params) {
    return axios.post(`${service.serviceOrder}/contractNoIsExist`, params);
  },
  // 物品签收异常登记记录
  signGoodsRecord (params) {
    return axios.post(
      `${service.serviceOrder}/orderGoods/sign/goods/record`,
      params
    );
  },
  // 物品回单异常登记记录
  receiptGoodsRecord (params) {
    return axios.post(
      `${service.serviceOrder}/orderGoods/receipt/goods/record`,
      params
    );
  },
  //订单列表查询  /search
  getOrderSearch (params) {
    return axios.post(`${service.serviceOrder}/search`, params);
  },
  //订单货物跟踪  单个预警预报
  getSingleInfo (orderId) {
    return axios.post(`${service.serviceOrder}/single/refreshere/${orderId}`);
  }
};
